//
//  PPMineTableViewController.m
//  pet
//
//  Created by 陈无忌 on 11/15/14.
//  Copyright (c) 2014 whalefin. All rights reserved.
//

#import "PPMineTableViewController.h"
#import "PPSystemConfiguraton.h"
#import "supportingHeadFiles.h"

@interface PPMineTableViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *userAvatar;
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *userAdressLabel;
@property (weak, nonatomic) IBOutlet UILabel *telephone;

@property (weak, nonatomic) PPSystemConfiguraton *config;

@end

@implementation PPMineTableViewController

- (PPSystemConfiguraton *)config
{
    if (!_config) {
        _config = [PPSystemConfiguraton sharedSystemConfiguration];
    }
    return _config;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.config getUserInfowithComepletion:^{
        [self staticViewData];
    }];
    
}

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableView setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}


- (void)staticViewData
{
    PPUserInfo *user = self.config.userInfo;
    [self.userAvatar setImageWithURL:[PPImageUrl getImageUrl:user.userAvatar] placeholderImage:[UIImage imageNamed:@"defaultAvatar"] usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    self.userNameLabel.text = user.userName;
    self.userAdressLabel.text = user.address;
    self.telephone.text = [NSString stringWithFormat:@"宠缘号：%@",user.phoneNum];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

@end
